//
//  ActivityVC.m
//  SelfDrivingTravelling-IOS
//
//  Created by Teplot_01 on 16/7/21.
//  Copyright © 2016年 Teplot_01. All rights reserved.
//

#import "ActivityVC.h"
#import "activityCell.h"
#import "ActivityDetailVC.h"
#import "ActivityListVC.h"
#import "ActivitySearchVC.h"
#import "MyJoinClubDetailVC.h"
@interface ActivityVC ()<UIScrollViewDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UITableViewDelegate,UITableViewDataSource,SDCycleScrollViewDelegate>
@end

@implementation ActivityVC
{
    UICollectionView *_collectionView;
    UITableView *_scrollTabView;
    UITableView *_huiguTabView;
    UITextField *_searchBarTf;
    
    NSDictionary *_responseDicAd;
    NSDictionary *_responseDic;
    NSMutableArray *_status3Arr;
    NSMutableArray *_status2Arr;
    NSMutableArray *_status1Arr;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self addSearchBar];
    [self requestForClubAd];
    [self requsetForActityList];
    [self initCollectionView];
}
//导航栏添加搜索框
- (void)addSearchBar{
    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0,  0, KScreenWidth, 33)];
    UIImageView *logoImageV = [[UIImageView alloc]initWithFrame:CGRectMake(0, -10, 50, 50)];
    logoImageV.image = [UIImage imageNamed:@"logo_transparent"];
    [bgView addSubview:logoImageV];
    _searchBarTf = [[UITextField alloc]initWithFrame:CGRectMake(60, 0, KScreenWidth-80, 33)];
    _searchBarTf.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 0)];
    _searchBarTf.leftViewMode = UITextFieldViewModeAlways;
    _searchBarTf.placeholder = @"搜索活动";
    _searchBarTf.tintColor = [UIColor blackColor];
    _searchBarTf.font = [UIFont systemFontOfSize:14];
    _searchBarTf.backgroundColor = blackLineColore;
    _searchBarTf.layer.borderWidth = 1;
    _searchBarTf.layer.borderColor = [UIColor grayColor].CGColor;
    _searchBarTf.layer.cornerRadius = 8;
    
    UIButton *searchBtn =[[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth-120, 3, 35, 30)];
    _searchBarTf.rightView = searchBtn;
    _searchBarTf.rightViewMode = UITextFieldViewModeAlways;
    searchBtn.backgroundColor = White_Color;
    searchBtn.layer.cornerRadius = 5;
    [searchBtn setImage:[UIImage imageNamed:@"组-3"] forState:UIControlStateNormal];
    searchBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [searchBtn addTarget:self action:@selector(searchAction) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:_searchBarTf];
    [_searchBarTf addSubview:searchBtn];

    self.navigationItem.titleView = bgView;
}
- (void)requestForClubAd{
    NSDictionary *parameters = @{
                                 @"userID": [NSString readToNSDefaultsWithKey:kId],
                                 @"status":@"0",
                                 @"isFeatured":@"1",
                                 @"pageNum": @"1",
                                 @"pageSize":@"10",
                                 };
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager POST:@"http://115.28.152.130/tour/v1/club/clubListByUserID.action" parameters:parameters success:^(NSURLSessionDataTask *operation, id responseObject) {
        [_collectionView.mj_header endRefreshing];
        _responseDicAd = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"%@>>>>",_responseDicAd);
//        NSString *error = _responseDic[@"code"];
        if (![_responseDic[@"code"] isEqualToString:@"0000"]) {
//            [SVProgressHUD showErrorWithStatus:[NSString errorStringWithCode:error]];
        }else{
            [_scrollTabView reloadData];
        }
        
    } failure:^(NSURLSessionDataTask *operation, NSError *error) {
        [SVProgressHUD showErrorWithStatus:@"请求失败"];
    }];
}
- (void)requsetForActityList{
    //参数
    NSDictionary *parameters = @{
//                                 @"clubId":@"1",
//                                 @"pageNo": @"1",
//                                 @"pageSize": @"10",
                                 };
    [SVProgressHUD showWithStatus:@"请求中"];
//    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.requestSerializer=[AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager POST:@"http://115.28.152.130/tour/v1/activity/listWithStatus.action" parameters:parameters success:^(NSURLSessionDataTask *operation, id responseObject) {
        [_collectionView.mj_header endRefreshing];
        _responseDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"%@<<<<>>>>",_responseDic);
        _status1Arr = _responseDic[@"list1"];
        _status2Arr = _responseDic[@"list2"];
        _status3Arr = _responseDic[@"list3"];
        NSString *error = _responseDic[@"code"];
        if (![_responseDic[@"code"] isEqualToString:@"0000"]) {
            [SVProgressHUD showErrorWithStatus:[NSString errorStringWithCode:error]];
        }else{
            [_collectionView reloadData];
            [_huiguTabView reloadData];
            [self requestForClubAd];
            [SVProgressHUD dismiss];
        }
        
    } failure:^(NSURLSessionDataTask *operation, NSError *error) {
        [SVProgressHUD showErrorWithStatus:@"请求活动列表失败"];
        [SVProgressHUD dismiss];
    }];
}
//创建一个CollectionView
- (void)initCollectionView{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    //设置整个collectionView的内边距
    CGFloat paddingY = 10;
    CGFloat paddingX = 10;
    layout.sectionInset = UIEdgeInsetsMake(paddingY, paddingX, paddingY, paddingX);
    //设置每个格子的尺寸
    layout.itemSize = CGSizeMake(KScreenWidth/2 - 20, 160);
    //设置headerView
    [layout setHeaderReferenceSize:CGSizeMake(KScreenWidth, 200)];
    //设置footView  我们出发喽 和 往期精彩回顾 放到footerView上
    [layout setFooterReferenceSize:CGSizeMake(KScreenWidth, 840)];//高度需要后期调整
    //设置对齐方式
    [layout setScrollDirection:UICollectionViewScrollDirectionVertical];
    _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight ) collectionViewLayout:layout];
    _collectionView.dataSource = self;
    _collectionView.delegate = self;
    _collectionView.backgroundColor = [UIColor whiteColor];
    UITapGestureRecognizer *tapGest = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(panGestFinger:)];
    tapGest.numberOfTapsRequired = 2;
    [_collectionView addGestureRecognizer:tapGest];
    [self.view addSubview:_collectionView];
    [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"MyCollectionViewCell"];
    
    //最上面TableView
    _scrollTabView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 200)];
    _scrollTabView.delegate = self;
    _scrollTabView.dataSource = self;
    [_collectionView addSubview:_scrollTabView];
    
    //火热报名中的label
    UILabel *baomingLb = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-85)/2, 160, 85, 30)];
    baomingLb.textAlignment = NSTextAlignmentCenter;
    baomingLb.font = [UIFont systemFontOfSize:16];
    baomingLb.textColor = RGBCOLOR(63, 63, 63);
    baomingLb.text = @"火热报名中";
    [_collectionView addSubview:baomingLb];
    
    UILabel *line1 = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-85)/2, 192, 85, .5)];
    line1.backgroundColor = RGBCOLOR(63, 63, 63);
    [_collectionView addSubview:line1];
    
    //查看更多精彩活动Btn
    UIButton *chakangengduoBtn = [[UIButton alloc]initWithFrame:CGRectMake(100, 500+50, KScreenWidth - 200, 40)];
    chakangengduoBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    chakangengduoBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [chakangengduoBtn setTitleColor:orangeTextColor forState:UIControlStateNormal];
    [chakangengduoBtn setTitle:@"查看更多热门活动" forState:UIControlStateNormal];
    chakangengduoBtn.layer.borderWidth = 1;
    chakangengduoBtn.layer.borderColor = LighterGrayColor.CGColor;
    chakangengduoBtn.layer.cornerRadius = 5;
    [chakangengduoBtn addTarget:self action:@selector(hotBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [_collectionView addSubview:chakangengduoBtn];
    
    UILabel *line2 = [[UILabel alloc]initWithFrame:CGRectMake(10, 600, KScreenWidth - 20, 1)];
    line2.backgroundColor = LighterGrayColor;
    [_collectionView addSubview:line2];
    
    //最下面放的是UITableView
    _huiguTabView = [[UITableView alloc]initWithFrame:CGRectMake(0, 620, KScreenWidth, 710)];
    _huiguTabView.delegate = self;
    _huiguTabView.dataSource = self;
    _huiguTabView.separatorStyle = NO;
    [_collectionView addSubview:_huiguTabView];
    
    //TableView下面放置button 查看更多往期活动
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(100, 1340, KScreenWidth - 200, 40)];
    btn.titleLabel.textAlignment = NSTextAlignmentCenter;
    btn.titleLabel.font = [UIFont systemFontOfSize:14];
    [btn setTitleColor:orangeTextColor forState:UIControlStateNormal];
    [btn setTitle:@"查看更多往期活动" forState:UIControlStateNormal];
    btn.layer.borderWidth = 1;
    btn.layer.borderColor = LighterGrayColor.CGColor;
    btn.layer.cornerRadius = 5;
    [btn addTarget:self action:@selector(wangqiBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [_collectionView addSubview:btn];
    
    [self refreshDown];
}
//下拉刷新
- (void)refreshDown{
    _collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        // 进入刷新状态后会自动调用这个block
        [self requestForClubAd];
        [self requsetForActityList];
    }];
}
#pragma mark -- UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 4;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellIDa = @"MyCollectionViewCell";
    UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIDa forIndexPath:indexPath];
    cell.layer.borderWidth = 1;
    cell.layer.borderColor = superBackgroundColor.CGColor;
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth/2 - 20, 100)];
    imageView.layer.masksToBounds = YES;
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    if (_status1Arr.count<4) {
    }else{
        NSString *urlStr = _responseDic[@"list1"][indexPath.row][@"coverImgURL"];
        [imageView sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"picture_8"]];
        for (id subView in cell.contentView.subviews) {
            [subView removeFromSuperview];
        }
        [cell.contentView addSubview:imageView];
        
        UILabel *cityName = [[UILabel alloc]initWithFrame:CGRectMake(8, 105, 129, 20)];
        cityName.text = _responseDic[@"list1"][indexPath.row][@"title"];
        cityName.textColor = RGBCOLOR(86, 114, 54);
        cityName.font = [UIFont systemFontOfSize:16];
        [cell.contentView addSubview:cityName];
        
        UILabel *jianjieLb = [[UILabel alloc]initWithFrame:CGRectMake(8, 128, 129, 20)];
        jianjieLb.text = _responseDic[@"list1"][indexPath.row][@"gotoReason"];
        jianjieLb.textColor = [UIColor grayColor];
        jianjieLb.font = [UIFont systemFontOfSize:12];
        [cell.contentView addSubview:jianjieLb];
    }
    return cell;
}
//item点击时调用
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    ActivityDetailVC *vc = [[ActivityDetailVC alloc]init];
    vc.status = @"1";
    vc.activityId = _responseDic[@"list1"][indexPath.row][@"id"];
    vc.activityHtmlUrlStr = _responseDic[@"list1"][indexPath.row][@"htmlUrl"];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma - mark UITableView delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if ([tableView isEqual:_scrollTabView]) {
        return 1;
    }else{
        return _status3Arr.count+1;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([tableView isEqual:_scrollTabView]) {
        UITableViewCell *cell = [[UITableViewCell alloc]init];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        NSArray *arr = _responseDicAd[@"list"];
        NSInteger imageCount = arr.count;
        NSInteger height = 150;
        SDCycleScrollView *_topCycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, KScreenWidth, height) delegate:self placeholderImage:nil];
        _topCycleScrollView.tag = 100;
        [cell.contentView addSubview:_topCycleScrollView];
        NSMutableArray *_adUrlArr = [[NSMutableArray alloc]init];
        for (int i = 0; i<imageCount; i++){
            NSString *urlStr = _responseDicAd[@"list"][i][@"logo"];
            //定向拼接替换logo的id标识
            NSString *latreStr = [urlStr substringFromIndex:47];//.png或者.jpg
            urlStr = [urlStr substringToIndex:40];
            NSString *userId = _responseDicAd[@"list"][i][@"userID"];
            urlStr = [NSString stringWithFormat:@"%@%@%@%@",urlStr, @"user/",userId,latreStr];
            NSDate *currentDate = [NSDate date];
            NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
            [dateFormatter setDateFormat:@"YYYYMMddHHmmssSSS"];
            NSString *dateString = [dateFormatter stringFromDate:currentDate];
            [_adUrlArr addObject:[NSString stringWithFormat:@"%@%@%@",urlStr, @"?",dateString]];
        }
        _topCycleScrollView.localizationImageNamesGroup = _adUrlArr;
        _topCycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
        _topCycleScrollView.backgroundColor = White_Color;
        _topCycleScrollView.autoScrollTimeInterval = 3;
        _topCycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
        return cell;
    }else{
        if (indexPath.row == 0) {
            UITableViewCell *cell = [[UITableViewCell alloc]init];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            //我们出发啦label
            UILabel *chufaLb = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-85)/2, 0, 85, 30)];
            chufaLb.textAlignment = NSTextAlignmentCenter;
            chufaLb.font = [UIFont systemFontOfSize:16];
            chufaLb.textColor = RGBCOLOR(63, 63, 63);
            chufaLb.text = @"我们出发咯";
            [cell.contentView addSubview:chufaLb];
            
            UILabel *line3 = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-85)/2, 32, 85, .5)];
            line3.backgroundColor = RGBCOLOR(63, 63, 63);
            [cell.contentView addSubview:line3];
            //我们出发咯 scrollview
            NSInteger imageNum = _status2Arr.count;
            NSInteger h = 150;
            SDCycleScrollView *_middleCycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 40, KScreenWidth, h) delegate:self placeholderImage:nil];
            _middleCycleScrollView.tag = 101;
            [cell.contentView addSubview:_middleCycleScrollView];
            NSMutableArray *_middleUrlArr = [[NSMutableArray alloc]init];
            NSMutableArray *_middleTitleArr = [[NSMutableArray alloc]init];
            for (int i = 0; i<imageNum; i++){
                NSString *_urlStr = _responseDic[@"list2"][i][@"coverImgURL"];
                NSString *_titleStr = _responseDic[@"list2"][i][@"title"];
                if (_urlStr == nil) {
                    [_middleUrlArr addObject:@"http://115.28.152.130/tour/activityHtml/234.html"];
                }else{
                    [_middleUrlArr addObject:_urlStr];
                }
                
                [_middleTitleArr addObject:_titleStr];
            }
            _middleCycleScrollView.localizationImageNamesGroup = _middleUrlArr;
            _middleCycleScrollView.titlesGroup = _middleTitleArr;
            _middleCycleScrollView.placeholderImage = [UIImage imageNamed:@"huodong_banner"];
            _middleCycleScrollView.autoScrollTimeInterval = 3;
            _middleCycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
            _middleCycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
            
            UIButton *chakangBtn = [[UIButton alloc]initWithFrame:CGRectMake(100, 200, KScreenWidth - 200, 40)];
            chakangBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
            chakangBtn.titleLabel.font = [UIFont systemFontOfSize:14];
            [chakangBtn setTitleColor:orangeTextColor forState:UIControlStateNormal];
            [chakangBtn setTitle:@"查看更多精彩活动" forState:UIControlStateNormal];
            chakangBtn.layer.borderWidth = 1;
            chakangBtn.layer.borderColor = LighterGrayColor.CGColor;
            chakangBtn.layer.cornerRadius = 5;
            [chakangBtn addTarget:self action:@selector(moreBtnAction) forControlEvents:UIControlEventTouchUpInside];
            [cell.contentView addSubview:chakangBtn];
            
            //线
            UILabel *line2 = [[UILabel alloc]initWithFrame:CGRectMake(10, 250, KScreenWidth - 20, 1)];
            line2.backgroundColor = LighterGrayColor;
            [cell.contentView addSubview:line2];
            
            //往期label
            UILabel *wangqihuiguLb = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-100)/2, 265, 100, 30)];
            wangqihuiguLb.textAlignment = NSTextAlignmentCenter;
            wangqihuiguLb.font = [UIFont systemFontOfSize:16];
            wangqihuiguLb.textColor = RGBCOLOR(63, 63, 63);
            wangqihuiguLb.text = @"往期精彩回顾";
            [cell.contentView addSubview:wangqihuiguLb];
            
            UILabel *line4 = [[UILabel alloc]initWithFrame:CGRectMake((KScreenWidth-100)/2, 298, 100, .5)];
            line4.backgroundColor = RGBCOLOR(63, 63, 63);
            [cell.contentView addSubview:line4];
            return cell;
        }else{
            activityCell *cell = [[NSBundle mainBundle]loadNibNamed:@"activityCell" owner:nil options:nil][0];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.title.text = _responseDic[@"list3"][indexPath.row-1][@"title"];
            cell.city.text = _responseDic[@"list3"][indexPath.row-1][@"destination"];
            NSString *timeStr = _responseDic[@"list3"][indexPath.row-1][@"stratTime"];
            timeStr = [timeStr substringToIndex:10];
            cell.time.text = timeStr;
            NSString *startStr = _responseDic[@"list3"][indexPath.row-1][@"stratTime"];
            startStr = [startStr substringToIndex:10];
            NSString *endStr = _responseDic[@"list3"][indexPath.row-1][@"endTime"];
            endStr = [endStr substringToIndex:10];
            NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ;
            [formatter setDateFormat:@"yyyy-MM-dd"];
            NSDate *starDate=[formatter dateFromString:startStr];
            NSDate *endDate=[formatter dateFromString:endStr];
            NSCalendar *calendar = [NSCalendar currentCalendar];
            unsigned int unitFlags = NSCalendarUnitDay;
            NSDateComponents *times = [calendar components:unitFlags fromDate:starDate toDate:endDate options:0];
            cell.days.text = [NSString stringWithFormat:@"%ld%@",(long)[times day],@"天"];
            NSString *urlStr = _responseDic[@"list3"][indexPath.row-1][@"coverImgURL"];
            cell.corveImage.layer.masksToBounds = YES;
            cell.corveImage.contentMode = UIViewContentModeScaleAspectFill;
            [cell.corveImage sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"默认图片"]];
            //cell的分割线
            UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 80, KScreenWidth, 0.3)];
            lineView.backgroundColor = RGBCOLOR(63, 63, 63);
            [cell.contentView addSubview:lineView];
            return cell;
        }
    }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row==0) {
    }else{
        ActivityDetailVC *vc = [[ActivityDetailVC alloc]init];
        vc.status = @"3";
        vc.activityId = _responseDic[@"list3"][indexPath.row-1][@"id"];
        vc.activityHtmlUrlStr = _responseDic[@"list3"][indexPath.row-1][@"htmlUrl"];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([tableView isEqual:_scrollTabView]) {
        return 150;
    }else{
        if (indexPath.row == 0) {
            return 310;
        }else{
            return 80;
        }
    }
    
}
- (void)hotBtnAction{
    ActivityListVC *vc = [[ActivityListVC alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    vc.status = @"1";
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)moreBtnAction{
    ActivityListVC *vc = [[ActivityListVC alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    vc.status = @"2";
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)wangqiBtnAction{
    ActivityListVC *vc = [[ActivityListVC alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    vc.status = @"3";
    [self.navigationController pushViewController:vc animated:YES];
}
#pragma - mark SDCycleScrollView delegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    if (cycleScrollView.tag == 100) {
        MyJoinClubDetailVC *vc = [[MyJoinClubDetailVC alloc]init];
        vc.clubId = _responseDicAd[@"list"][index][@"id"];
        vc.clubName = _responseDicAd[@"list"][index][@"clubName"];
        
        NSString *urlStr = _responseDicAd[@"list"][index][@"logo"];
        //定向拼接替换logo的id标识
        urlStr = [urlStr substringToIndex:40];
        NSString *userId = _responseDicAd[@"list"][index][@"userID"];
        urlStr = [NSString stringWithFormat:@"%@%@%@%@",urlStr, @"user/",userId,@".png"];
        NSDate *currentDate = [NSDate date];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"YYYYMMddHHmmssSSS"];
        NSString *dateString = [dateFormatter stringFromDate:currentDate];
        vc.clubIconStr = [NSString stringWithFormat:@"%@%@%@",urlStr, @"?",dateString];
        vc.clubSummary = _responseDicAd[@"list"][index][@"clubSummary"];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }
    if (cycleScrollView.tag == 101) {
        ActivityDetailVC *vc = [[ActivityDetailVC alloc]init];
        vc.status = @"2";
        vc.activityId = _responseDic[@"list2"][index][@"id"];
        vc.activityHtmlUrlStr = _responseDic[@"list2"][index][@"htmlUrl"];
        vc.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}
//搜索的方法
- (void)searchAction{
    [_searchBarTf endEditing:YES];
    ActivitySearchVC *vc = [[ActivitySearchVC alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    vc.searchKey = _searchBarTf.text;
    _searchBarTf.text = nil;
    [self.navigationController pushViewController:vc animated:YES];
}
//轻轻拖动 键盘消失
- (void)panGestFinger:(UITapGestureRecognizer *)sender{
    [_searchBarTf endEditing:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
